package com.hyt.it.ogt.kq.main.controller.gov;

import com.hyt.it.ogt.kq.common.gov.config.arrange.CommonLockKeyCreator;
import com.hyt.it.ogt.kq.common.gov.config.swagger.ApiVersionConstant;
import com.hyt.it.ogt.kq.common.gov.constant.ResponseCode;
import com.hyt.it.ogt.kq.main.controller.base.BaseController;
import com.hyt.it.ogt.kq.service.gov.model.param.DeskTopExportParam;
import com.hyt.it.ogt.kq.service.gov.model.vo.SignVo;
import com.hyt.it.ogt.kq.service.gov.service.ITaskSignService;
import com.hyt.log.annotation.Log;
import com.hyt.progress.creator.anno.ProgressAnno;
import com.hyt.swagger.ApiVersion;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiOperationSort;
import io.swagger.annotations.ApiSort;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;
import com.hyt.common.apiInfor.ApiResponse;
import javax.annotation.Resource;

@RestController
@Api(tags = "42.签到表、桌贴接口", value = "签到表、桌贴接口")
@ApiSort(value = 42)
@RequestMapping("/kw/gov/sign")
@Slf4j
public class SignController extends BaseController {

    @Resource
    ITaskSignService iTaskSignService;

    @ApiOperation(value = "42.1.导出桌贴")
    @ApiOperationSort(value = 1)
    @ApiVersion(group = ApiVersionConstant.V2_4_10)
    @Log(module = "导出桌贴", business = "导出桌贴")
    @ProgressAnno(total = 100, timeoutSeconds = 60
            * 10, errorCode = 43500301, canConcurrent = false, lockKeyCreator = CommonLockKeyCreator.class)
    @PostMapping(value = "/downloadDeskTop")
    public void downloadDeskTop(@RequestBody DeskTopExportParam param){
        iTaskSignService.exportDeskTop(param);
    }

    @ApiOperation(value = "42.2.导出签到表")
    @ApiOperationSort(value = 2)
    @ApiVersion(group = ApiVersionConstant.V2_4_10)
    @Log(module = "导出签到表", business = "导出签到表")
    @ProgressAnno(total = 100, timeoutSeconds = 60
            * 10, errorCode = 43500302, canConcurrent = false, lockKeyCreator = CommonLockKeyCreator.class)
    @GetMapping(value = "/downloadSign")
    public void downloadSign(String taskId){
        iTaskSignService.exportSign(taskId);
    }

    @ApiOperation(value = "42.3.查询考生数量和模板图片")
    @ApiOperationSort(value = 3)
    @ApiVersion(group = ApiVersionConstant.V2_4_10)
    @Log(module = "查询考生数量和模板图片", business = "导出签到表")
    @GetMapping(value = "/querySign")
    public ApiResponse<SignVo> querySign(String taskId){

        return ApiResponse.<SignVo>builder()
                .code(ResponseCode.SUCCESS.getCode())
                .data(iTaskSignService.querySign(taskId))
                .build();

    }
}
